<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>intersectionWith</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const intersectionWith = (a, b, handler) =>
            a.filter(x => b.findIndex(y => handler(x, y)) !== -1);
        console.log(intersectionWith(
            [1, 1.2, 1.5, 3, 0],
            [1.9, 3, 0, 3.9],
            (a, b) => Math.round(a) === Math.round(b)
        ));
    </script>
</body>

</html>